package com.navi.mould1.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


@Controller
public class PageController {

    @Value("${session.reportUrl}")
    private String reportUrl;

    @RequestMapping(value = "/goto")
    public ModelAndView gotoPage(String page, String func_code, HttpServletRequest request) {
        HttpSession session = request.getSession();
        String userId = (String) session.getAttribute("userId");
        ModelAndView mv = new ModelAndView();
        mv.setViewName(page);
        mv.addObject("reportUrl", reportUrl);
        if (userId == null) {
            mv.addObject("msg", "用户未登录，请先登录！");
            mv.setViewName("login-lte");
            return mv;
        }
        return mv;
    }
}
